package aiguigu03.field_method.method;

/**
 * ClassName: MethodTest
 * Package: aiguigu03.field_method.method
 * Description:
 *
 * @Author ZY
 * @Create 2024/9/22 21:41
 * @Version 1.0
 */
public class MethodTest {
    public static void main(String[] args) {
        Person p1 = new Person();
        p1.eat();
        p1.sleep(8);
        String info = p1.interests("打篮球");
    }
}
class Person{
    //属性
    String name;
    int age;
    char gender;

    //方法
    public void eat(){
        System.out.println("吃饭");
    }

    public void sleep(int hour){
        System.out.println("人至少每天睡眠" + hour + "小时");
    }

    public String interests(String hobby){
        String info = "我的爱好是" + hobby;
        System.out.println(info);
        return info;
    }

    public int getAge(){
        return age;
    }
}
